/*
 * Copyright (C) 2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef IMAGE_KNIFE_C_KEKE_TRANSFORMATION_SWIRL_H
#define IMAGE_KNIFE_C_KEKE_TRANSFORMATION_SWIRL_H

#include "gpu_swirl_filter.h"
#include "transformation_gpu.h"
#include "transformation/transformation_option.h"

namespace ImageKnifePro {
class TransformationSwirl : public TransformationGPU {
public:
    explicit TransformationSwirl(std::shared_ptr<TransformationOption> option)
    {
        const float defaultRadius = 200;
        const float defaultAngle = 0.9;
        const float defaultCenter = 0.5;
        const size_t xIndex = 2;
        const size_t yIndex = 3;
        const size_t argc = 4;

        float radius = defaultRadius;
        float angle = defaultAngle;
        float centerX = defaultCenter;
        float centerY = defaultCenter;

        if (option->f32.size() >= argc) {
            radius = option->f32[0];
            angle = option->f32[1];
            centerX = option->f32[xIndex];
            centerY = option->f32[yIndex];
        }

        info_ = "Default Swirl:" + std::to_string(radius) + "," + std::to_string(angle) +
                "," + std::to_string(centerX) + "," + std::to_string(centerY);
        SetGpuFilter(std::make_shared<GPUSwirlFilter>(radius, angle, centerX, centerY));
    }
private:
    std::string info_;

    std::string GetTransformInfo() override
    {
        return info_;
    }
};

}

#endif //IMAGE_KNIFE_C_KEKE_TRANSFORMATION_SWIRL_H
